package com.sntk.organauthomanager.application.controller;

import com.sntk.organauthomanager.application.dto.LoginUser;
import com.sntk.organauthomanager.application.dto.ResponseData;
import com.sntk.organauthomanager.application.service.LoginApplicationService;
import com.sntk.organauthomanager.infrastructure.autho.PassToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: LoginController
 * @author: wgchao
 * @createTime: 2020/8/5 10:00 AM
 * @Description: TODO
 */
@RestController
@RequestMapping("/sinohis/osm/external/login")
@Api(value="LoginController",tags={"认证授权管理"})
public class LoginController {
    @Autowired
    private LoginApplicationService loginApplicationService;

    /**
     * 申请accesstoken
     * @return
     */
    @PostMapping("/passtoken")
    @PassToken
    @ApiOperation(value="申请accesstoken")
    public ResponseData<Map> applyAccessToken(@RequestBody LoginUser loginUser){
        Map<String, String> map = new HashMap<>();
        map.put("accessToken", loginApplicationService.applyAccessToken(loginUser));
        return ResponseData.success().setData(map);
    }

}
